﻿
using PEProtocol;
using PNet;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BattleServer
{
    public class LoginToken : IOCPToken<NetMsg>
    {
        protected override void Connected(bool result)
        {
            if (result)
            {
                this.LogGreen($"[Token:[{TokenID}]=> UnityClient Connnected:{result}]");
                BattleProcess.Instance.LoginNet.AddServerMsg(new LoginPack(new NetMsg() { CMD = CMD.OnClient2LoginConnected }, this));
            }
            else
            {

                this.LogYellow($"[Token:[{TokenID}]=> UnityClient Connnected:{result}]");
            }
        }

        protected override void OnDisconnected()
        {
            BattleProcess.Instance.LoginNet.AddServerMsg(new LoginPack(new NetMsg() { CMD = CMD.OnClient2LoginDisconnected }, this));
            this.LogGreen($"[Token:[{TokenID}]=> UnityClient DisConnnected!");

        }

        protected override void OnReceiveMsg(NetMsg msg)
        {
            BattleProcess.Instance.LoginNet.AddServerMsg(new LoginPack(msg, this));
        }
    }
}
